home *** CD-ROM | disk | FTP | other *** search
- VERSION 2.00
- Begin Form Modules
- BackColor = &H00C0C0C0&
- BorderStyle = 1 'Fixed Single
- Caption = "Modules Active On System"
- ClientHeight = 5790
- ClientLeft = 1095
- ClientTop = 1500
- ClientWidth = 7365
- ControlBox = 0 'False
- Height = 6195
- Left = 1035
- LinkTopic = "Form1"
- MaxButton = 0 'False
- MinButton = 0 'False
- ScaleHeight = 5790
- ScaleWidth = 7365
- Top = 1155
- Width = 7485
- Begin ListBox ListTask
- Height = 225
- Left = 480
- TabIndex = 10
- Top = 5520
- Visible = 0 'False
- Width = 2775
- End
- Begin ListBox ListHidden
- Height = 225
- Left = 3660
- Sorted = -1 'True
- TabIndex = 6
- Top = 5520
- Visible = 0 'False
- Width = 3375
- End
- Begin CommandButton CmdOkay
- BackColor = &H00C0C0C0&
- Cancel = -1 'True
- Caption = "O &K A Y"
- Default = -1 'True
- Height = 375
- Left = 3840
- TabIndex = 4
- TabStop = 0 'False
- Top = 5100
- Width = 3135
- End
- Begin CommandButton CmdDetails
- BackColor = &H00C0C0C0&
- Caption = "Show &Details"
- Height = 375
- Left = 3840
- TabIndex = 3
- TabStop = 0 'False
- Top = 4680
- Width = 3135
- End
- Begin CommandButton CmdRefresh
- BackColor = &H00C0C0C0&
- Caption = "&Refresh List"
- Height = 375
- Left = 420
- TabIndex = 2
- TabStop = 0 'False
- Top = 5100
- Width = 3135
- End
- Begin CommandButton CmdUnload
- BackColor = &H00C0C0C0&
- Caption = "&Unload Module"
- Height = 375
- Left = 420
- TabIndex = 1
- TabStop = 0 'False
- Top = 4680
- Width = 3135
- End
- Begin ListBox List1
- FontBold = 0 'False
- FontItalic = 0 'False
- FontName = "Terminal"
- FontSize = 9
- FontStrikethru = 0 'False
- FontUnderline = 0 'False
- Height = 2550
- Left = 360
- Sorted = -1 'True
- TabIndex = 0
- Top = 1560
- Width = 6675
- End
- Begin Label Label4
- Alignment = 2 'Center
- BackStyle = 0 'Transparent
- Caption = "Label4"
- ForeColor = &H00000000&
- Height = 315
- Left = 360
- TabIndex = 9
- Top = 4200
- Width = 6675
- End
- Begin Label Label3
- BackStyle = 0 'Transparent
- Caption = "Label1"
- FontBold = 0 'False
- FontItalic = 0 'False
- FontName = "Terminal"
- FontSize = 9
- FontStrikethru = 0 'False
- FontUnderline = 0 'False
- ForeColor = &H00000000&
- Height = 255
- Left = 360
- TabIndex = 8
- Top = 1320
- Width = 6675
- End
- Begin Label Label2
- Alignment = 2 'Center
- BackStyle = 0 'Transparent
- Caption = "Label1"
- ForeColor = &H00000080&
- Height = 435
- Left = 360
- TabIndex = 7
- Top = 660
- Width = 6675
- End
- Begin Label Label1
- Alignment = 2 'Center
- BackStyle = 0 'Transparent
- Caption = "Label1"
- ForeColor = &H00800000&
- Height = 435
- Left = 360
- TabIndex = 5
- Top = 180
- Width = 6675
- End
- Declare Sub FreeLibrary Lib "Kernel" (ByVal hModule%)
- Sub CmdDetails_Click ()
- If List1.ListIndex = -1 Or List1.ListCount = 0 Then
- MsgBox "No item selected!", 64, "Module Details"
- Exit Sub
- End If
- x = List1.ListIndex
- sModule$ = ExtractField(x, 1)
- hModule$ = Trim$(ExtractField(x, 2))
- iUsage$ = Trim$(ExtractField(x, 3))
- iSize$ = Format$(Val(ExtractField(x, 4)), "###,###,##0")
- sFullPath$ = LCase$(ExtractField(x, 5))
-
- msg$ = "Module Name:" + Chr$(9) + sModule$ + nl
- msg$ = msg$ + "Handle:" + Chr$(9) + Chr$(9) + hModule$ + nl
- msg$ = msg$ + "Usage Count:" + Chr$(9) + iUsage$ + nl
- msg$ = msg$ + "Size (bytes):" + Chr$(9) + iSize$ + nl
- msg$ = msg$ + "Full Path:" + Chr$(9) + sFullPath$
- MsgBox msg$, 48, "Selected Module Details"
- List1.SetFocus
- End Sub
- Sub CmdOkay_Click ()
- Unload Me
- End Sub
- Sub CmdRefresh_Click ()
- List1.Visible = False
- Screen.MousePointer = 11
- RefreshView
- List1.Visible = True
- Screen.MousePointer = 0
- List1.SetFocus
- End Sub
- Sub CmdUnload_Click ()
- x = List1.ListIndex
- iUsage% = Val(ExtractField(x, 3))
- hModule% = Val(ExtractField(x, 2))
- ReturnString$ = Space$(255)
- GetToken List1.List(x), Chr$(9), 5, ReturnString$
- sAppType$ = Right$(TrimAtNull(ReturnString$), 3)
- 'If sAppType$ <> "exe" Then
- FreeLibrary hModule%
- ' Else
- ' MsgBox "Can NOT unload an EXE module.", 48, "Unload Module"
- ' End If
- If iUsage% = 1 Then
- CmdRefresh_Click
- Else
- sModule$ = ExtractField(x, 1)
- nhModule$ = JustifyRight(Format$(hModule%), " ", 6)
- niUsage$ = JustifyRight(Format$(iUsage% - 1), " ", 6)
- sApp$ = ExtractField(x, 5)
- ReturnString$ = Space$(255)
- FromPath sApp$, "FullFileName", ReturnString$
- sApp$ = LCase$(TrimAtNull(ReturnString$))
- List1.RemoveItem x
- List1.AddItem sModule$ + Chr$(9) + nhModule$ + Chr$(9) + niUsage$ + Chr$(9) + sApp$
- List1.ListIndex = x
- LBfillModuleInfo ListHidden.hWnd, False
- End If
- AllDone:
- List1.SetFocus
- Exit Sub
- End Sub
- Function ExtractField$ (RecordItem, FieldItem)
- 'When using a hidden module like this, it is best to
- 'set the Sort property of both ListBoxes to the same value
- If RecordItem > ListHidden.ListCount Then
- ExtractField = ""
- Exit Function
- End If
- ThisRecord$ = ListHidden.List(RecordItem)
- delimiter$ = Chr$(9)
- If GetTokenCount(ThisRecord$, delimter$) > FieldItem Then
- ExtractField = ""
- Exit Function
- End If
- ReturnString$ = Space$(255)
- GetToken ThisRecord$, delimiter$, FieldItem, ReturnString$
- ExtractField = TrimAtNull(ReturnString$)
- End Function
- Sub Form_Load ()
- FormCenterScreen Me
- msg$ = "This example uses the LBfillModuleInfo routine." + nl
- msg$ = msg$ + "Using a hidden ListBox, it selects specific data."
- Label1.Caption = msg$
- msg$ = "Unload modules at your own risk!!!" + nl
- msg$ = msg$ + "Unloading an active module can cause a GPF!!!"
- Label2.Caption = msg$
- Label3.Caption = "Module Name" + Space$(9) + "Handle" + Space$(5) + "Usage" + Space$(4) + "File Name"
- ReDim tabsets%(4)
- tabsets%(0) = 0
- tabsets%(1) = 20 * 4
- tabsets%(2) = 30 * 4
- tabsets%(3) = 40 * 4
- tabsets%(4) = 50 * 4
- dummy% = OutMessage(List1.hWnd, 1043, 5, tabsets%(0))
- RefreshView
- Screen.MousePointer = 0
- End Sub
- Sub Form_Paint ()
- DoForm3D Me, "raised", 2, 0
- DoForm3D Me, "sunken", 2, 2
- DoControl3D List1, "sunken", 2
- End Sub
- Sub List1_DblClick ()
- CmdDetails_Click
- End Sub
- Sub RefreshView ()
- LBfillModuleInfo ListHidden.hWnd, False
- If ListHidden.ListCount = 0 Then
- Label4.Caption = ""
- Exit Sub
- End If
- List1.Clear
- For x = 0 To ListHidden.ListCount - 1
- sModule$ = ExtractField(x, 1)
- hModule$ = ExtractField(x, 2)
- iUsage$ = ExtractField(x, 3)
- sApp$ = ExtractField(x, 5)
- ReturnString$ = Space$(255)
- FromPath sApp$, "FullFileName", ReturnString$
- sApp$ = LCase$(TrimAtNull(ReturnString$))
- List1.AddItem sModule$ + Chr$(9) + hModule$ + Chr$(9) + iUsage$ + Chr$(9) + sApp$ + Chr$(9)
- Next x
- ItemCount% = ListHidden.ListCount
- If ItemCount% > 1 Then
- word$ = " modules "
- Else
- word$ = " module "
- End If
- Label4.Caption = Format$(ItemCount%, "###,##0") + " active" + word$ + "detected"
- List1.ListIndex = 0
- End Sub
-